import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getMatrixPage',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    postId: queryParams.postId,
    keywords: queryParams.keywords,
  }
  return request({
    url: '/getMatrixList',
    method: 'post',
    data: data
  })
}

// 分类名称
export function Single(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    category: queryParams.category,
  }
  return request({
    url: '/getCurriculumList',
    method: 'post',
    data: data
  })
}

// 添加
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId,
      postId: val.postId, // 岗位id
      post: val.post, //岗位
      curriculumClassificationId: val.curriculumClassificationId, //课程分类id
      curriculumClassification: val.curriculumClassification
    }
  }
  return request({
    url: '/addMatrix',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delMatrix',
    method: 'post',
    data: data
  })
}

// 课程名称弹框
export function Coursepopup(val) {
  const data = {
    theid: val.theid, //id
    postId: val.postId, //岗位 id
    post: val.post, //岗位
    curriculumClassificationId: val.curriculumClassificationId, //课程分类id
    curriculumClassification: val.curriculumClassification, //课程分类
    curriculumIds: val.curriculumIds //课程id列表
  }
  return request({
    url: '/updateMatrix',
    method: 'post',
    data: data
  })
}

// 培训矩阵看板
export function getTrainmatrix() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/trainMatrixBulletinBoard',
    method: 'post',
    data: data
  })
}